package com.study.myteach.命令模式;

import com.study.teacher.CalcCommand;
import com.study.teacher.Calculator;
import com.study.teacher.Command;

import java.util.ArrayList;

public class CalcApp {
    public static void main(String args[]) {
        Calculator cal = new Calculator();
		/*
		obj.calc('+', 15);
		obj.calc('-', 12);
		obj.calc('*', 3);
		obj.calc('/', 5);
		*/

        CalcCommand command1 =
                new CalcCommand(cal, '+', 15);
        command1.execute();

        CalcCommand command2 =
                new CalcCommand(cal, '-', 12);
        command2.execute();

        CalcCommand command3 =
                new CalcCommand(cal, '*', 3);
        command3.execute();

        CalcCommand command4 =
                new CalcCommand(cal, '/', 5);
        command4.execute();

        ArrayList<Command> lst = new ArrayList<Command>();
        lst.add(command1);
        lst.add(command2);
        lst.add(command3);
        lst.add(command4);

        for (int i = 0; i < lst.size(); i++) {
            ((Command) (lst.get(i))).execute();
        }

        System.out.println(cal.getResult());
    }
}
